home *** CD-ROM | disk | FTP | other *** search
/ Young Minds / Young Minds Interactive CD-ROM.ISO / kriegspi / xmove.c < prev    next >
Encoding:
C/C++ Source or Header  |  1987-06-30  |  1.0 KB  |  57 lines

  1. #ifndef lint
  2. static char rcsid[] = "$Header: xmove.c,v 1.5 87/03/31 17:41:49 schoch Exp $";
  3. #endif
  4.  
  5. #include "externs.h"
  6.  
  7. domove(from, to)
  8. {
  9.  
  10.     if (whose[from] != ourcolor) {
  11.     fprintf(stderr, "Moving wrong piece: %d at %d\n", whose[from], from);
  12.     return;
  13.     }
  14.     if (inp == NULL) {
  15.     message("Sorry, lost your opponent.", MESSAGE);
  16.     return;
  17.     }
  18.     fprintf(out, "%1c%1d-%1c%1d\r\n", from%10-1+'a', 9-from/10,
  19.     to%10-1+'a', 9-to/10);
  20.     if (movetry(from, to, ourcolor))
  21.     return;
  22.     if (ghost[to]) {        /* "capture" a ghost */
  23.     ghost_capture(to);
  24.     ghost[to] = 0;
  25.     }
  26. }
  27.  
  28. ghost_capture(p)
  29. {
  30.     display_capture(theircolor, ghost[p]);
  31. }
  32.  
  33. display_capture(color, piece)
  34. u_char color, piece;
  35. {
  36.     int i;
  37.     int n;
  38.  
  39.     if (color == WHITE)
  40.     n = 0;
  41.     else
  42.     n = 16;
  43.     for (i = 0; i < 16; i+=2)
  44.     if (captured[n+i] == 0)
  45.         break;
  46.     if (i >= 16)
  47.     for (i = 1; i < 16; i+=2)
  48.         if (captured[n+i] == 0)
  49.         break;
  50.     if (i >= 16) {
  51.     fprintf(stderr, "panic: can't find capture space.\n");
  52.     exit(1);
  53.     }
  54.     captured[i+n] = piece;
  55.     redraw_captured(i+n);
  56. }
  57.